Size: a a a

2020 February 16

AZ

Alex Zhukovsky in rust_offtopic
для этого нужнонайти самый частый по табличке символ + хвост, не так уж и сложно
источник

PP

Piu Piu in rust_offtopic
Re: ESbuild – A fast JavaScript bundler and minifier i...
       
Author here. I think the Rust vs. Go question is interesting. I actually originally wrote esbuild in Rust and Go, and Go was the clear winner.

The parser written in Go was both faster to compile and faster to execute than the parser in Rust. The Go version compiled something like 100x faster than Rust and ran at something around 10% faster (I forget the exact numbers, sorry). Based on a profile, it looked like the Go version was faster because GC happened on another thread while Rust had to run destructors on the same thread.

The Rust version also had other problems. Many places in my code had switch statements that branched over all AST nodes and in Rust that compiles to code which uses stack space proportional to the total stack space used by all branches instead of just the maximum stack space used by any one branch: https://github.com/rust-lang/rust/issues/34283. I believe the issue still isn't fixed. That meant that the Rust version quickly overflowed the stack if you had many nested JavaScript syntax constructs, which was easy to hit in large JavaScript files. There were also random other issues such as Rust's floating-point number parser not actually working in all cases: https://github.com/rust-lang/rust/issues/31407. I also had to spend a lot of time getting multi-threading to work in Rust with all of the lifetime stuff. Go had none of these issues.

The Rust version probably could be made to work at an equivalent speed with enough effort. But at a high-level, Go was much more enjoyable to work with. This is a side project and it has to be fun for me to work on it. The Rust version was actively un-fun for me, both because of all of the workarounds that got in the way and because of the extremely slow compile times. Obviously you can tell from the nature of this project that I value fast build times :)
       
constexpr, 6 hours ago
источник

P

Pavel in rust_offtopic
например, в текстовом редакторе тебе сказали "прокрути до средины файла", ты можешь перебирать символы, а можешь наугад листонуть к средине файла по размеру в байтах, статистически это будет средина по символам, там ты получаешь 10хххххх и ты можешь либо скипать вправо, пока не дойдёшь до начала, либо отмотать влево
источник

AZ

Alex Zhukovsky in rust_offtopic
Pavel
например, в текстовом редакторе тебе сказали "прокрути до средины файла", ты можешь перебирать символы, а можешь наугад листонуть к средине файла по размеру в байтах, статистически это будет средина по символам, там ты получаешь 10хххххх и ты можешь либо скипать вправо, пока не дойдёшь до начала, либо отмотать влево
ну так же и тут
источник

P

Pavel in rust_offtopic
Alex Zhukovsky
с файлом можно досикать до нужного момента, а потом немного вернуться пока кодирование не будет однозначным
ну, вот в хафмане сложно понять, когда ты однозначно декодировал, а когда — нет
источник

AZ

Alex Zhukovsky in rust_offtopic
короч я спать
источник

P

Pavel in rust_offtopic
смотри пример выше, со скрином из вики
источник

AZ

Alex Zhukovsky in rust_offtopic
Pavel
ну, вот в хафмане сложно понять, когда ты однозначно декодировал, а когда — нет
чтобы однозначно декодировать тебе нужен ноль + что-то еще
источник

AZ

Alex Zhukovsky in rust_offtopic
ноль должен встречаться часто, он не зря первый в таблице
источник

P

Pavel in rust_offtopic
там конец E, A и начало D дают D_,
источник

P

Pavel in rust_offtopic
и ты такой сидишь себе декодишь, пока не понимаешь, что пришёл к префиксу, которого нет
источник

λ

λоλторт in rust_offtopic
Piu Piu
Re: ESbuild – A fast JavaScript bundler and minifier i...
       
Author here. I think the Rust vs. Go question is interesting. I actually originally wrote esbuild in Rust and Go, and Go was the clear winner.

The parser written in Go was both faster to compile and faster to execute than the parser in Rust. The Go version compiled something like 100x faster than Rust and ran at something around 10% faster (I forget the exact numbers, sorry). Based on a profile, it looked like the Go version was faster because GC happened on another thread while Rust had to run destructors on the same thread.

The Rust version also had other problems. Many places in my code had switch statements that branched over all AST nodes and in Rust that compiles to code which uses stack space proportional to the total stack space used by all branches instead of just the maximum stack space used by any one branch: https://github.com/rust-lang/rust/issues/34283. I believe the issue still isn't fixed. That meant that the Rust version quickly overflowed the stack if you had many nested JavaScript syntax constructs, which was easy to hit in large JavaScript files. There were also random other issues such as Rust's floating-point number parser not actually working in all cases: https://github.com/rust-lang/rust/issues/31407. I also had to spend a lot of time getting multi-threading to work in Rust with all of the lifetime stuff. Go had none of these issues.

The Rust version probably could be made to work at an equivalent speed with enough effort. But at a high-level, Go was much more enjoyable to work with. This is a side project and it has to be fun for me to work on it. The Rust version was actively un-fun for me, both because of all of the workarounds that got in the way and because of the extremely slow compile times. Obviously you can tell from the nature of this project that I value fast build times :)
       
constexpr, 6 hours ago
Этот придурок небось LL парсер руками писал?
источник

AZ

Alex Zhukovsky in rust_offtopic
Pavel
там конец E, A и начало D дают D_,
тебе нужно максимум 2х символов чтобы понять однозначно что за буква
источник

PP

Piu Piu in rust_offtopic
λоλторт
Этот придурок небось LL парсер руками писал?
да. на го и на раст
источник

AZ

Alex Zhukovsky in rust_offtopic
в примере который я скинул - это 6
источник

λ

λоλторт in rust_offtopic
Piu Piu
да. на го и на раст
Земля ему стекловатой
источник

AZ

Alex Zhukovsky in rust_offtopic
001010 можно декодировать однозначно
источник

λ

λоλторт in rust_offtopic
Хотя про ишью с паттернматчингом это интересно
источник

PP

Piu Piu in rust_offtopic
λоλторт
Земля ему стекловатой
энивей на го получилось быстрей как он утверждает
источник

P

Pavel in rust_offtopic
Alex Zhukovsky
001010 можно декодировать однозначно
опять же, пример выше, тебе попадается AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, но первый бит ты пропустил, в итоге получишь кучу D
источник