Skip to content

Commit e399267

Browse files
committed
fix: remove thread_num
1 parent d128f75 commit e399267

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

benchmarks/multi_thread_comporess.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'objspace'
55
require 'zstd-ruby'
66
require 'thread'
7+
require "zstds"
78

89
GUESSES = (ENV['GUESSES'] || 1000).to_i
910
THREADS = (ENV['THREADS'] || 1).to_i
@@ -14,19 +15,14 @@
1415
json_string = File.read("./samples/#{sample_file_name}")
1516

1617
queue = Queue.new
17-
# queue = []
1818
GUESSES.times { queue << json_string }
19-
# stream = Zstd::StreamingCompress.new(thread_num: THREADS)
2019
THREADS.times { queue << nil }
2120
THREADS.times.map {
2221
Thread.new {
2322
while str = queue.pop
24-
# stream = Zstd::StreamingCompress.new(thread_num: THREADS)
25-
#stream << str
26-
#stream << str
27-
#stream << str
28-
#stream.flush
29-
Zstd.compress(str, thread_num: 1)
23+
stream = Zstd::StreamingCompress.new
24+
stream << str
25+
stream.finish
3026
end
3127
}
3228
}.each(&:join)

ext/zstdruby/common.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ static size_t zstd_compress(ZSTD_CCtx* const ctx, ZSTD_outBuffer* output, ZSTD_i
4343

4444
static void set_compress_params(ZSTD_CCtx* const ctx, VALUE level_from_args, VALUE kwargs)
4545
{
46-
ID kwargs_keys[3];
46+
ID kwargs_keys[2];
4747
kwargs_keys[0] = rb_intern("level");
4848
kwargs_keys[1] = rb_intern("dict");
49-
kwargs_keys[2] = rb_intern("thread_num");
50-
VALUE kwargs_values[3];
51-
rb_get_kwargs(kwargs, kwargs_keys, 0, 3, kwargs_values);
49+
VALUE kwargs_values[2];
50+
rb_get_kwargs(kwargs, kwargs_keys, 0, 2, kwargs_values);
5251

5352
int compression_level = ZSTD_CLEVEL_DEFAULT;
5453
if (kwargs_values[0] != Qundef && kwargs_values[0] != Qnil) {
@@ -68,15 +67,6 @@ static void set_compress_params(ZSTD_CCtx* const ctx, VALUE level_from_args, VAL
6867
rb_raise(rb_eRuntimeError, "%s", "ZSTD_CCtx_loadDictionary failed");
6968
}
7069
}
71-
72-
if (kwargs_values[2] != Qundef && kwargs_values[2] != Qnil) {
73-
int thread_num = NUM2INT(kwargs_values[2]);
74-
size_t const r = ZSTD_CCtx_setParameter(ctx, ZSTD_c_nbWorkers, thread_num);
75-
if (ZSTD_isError(r)) {
76-
rb_warn("Note: the linked libzstd library doesn't support multithreading.Reverting to single-thread mode. \n");
77-
}
78-
// ZSTD_CCtx_setParameter(ctx, ZSTD_c_jobSize, thread_num);
79-
}
8070
}
8171

8272
static void set_decompress_params(ZSTD_DCtx* const dctx, VALUE kwargs)

ext/zstdruby/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
have_func('rb_gc_mark_movable')
44

5-
$CFLAGS = '-I. -O3 -std=c99 -DZSTD_STATIC_LINKING_ONLY -DZSTD_MULTITHREAD -pthread'
5+
$CFLAGS = '-I. -O3 -std=c99 -DZSTD_STATIC_LINKING_ONLY -DZSTD_MULTITHREAD -pthread -DDEBUGLEVEL=0'
66
$CPPFLAGS += " -fdeclspec" if CONFIG['CXX'] =~ /clang/
77

88
Dir.chdir File.expand_path('..', __FILE__) do

0 commit comments

Comments
 (0)