mirror of
https://github.com/lune-org/lune.git
synced 2025-04-20 03:43:49 +01:00
fix: remove redundant multi-threading code
This commit is contained in:
parent
53b53a27fd
commit
6f4b2f4c31
4 changed files with 9 additions and 104 deletions
75
Cargo.lock
generated
75
Cargo.lock
generated
|
@ -468,30 +468,6 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-deque"
|
|
||||||
version = "0.8.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"crossbeam-epoch",
|
|
||||||
"crossbeam-utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-epoch"
|
|
||||||
version = "0.9.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"cfg-if",
|
|
||||||
"crossbeam-utils",
|
|
||||||
"memoffset",
|
|
||||||
"scopeguard",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.8.18"
|
version = "0.8.18"
|
||||||
|
@ -1156,7 +1132,6 @@ dependencies = [
|
||||||
"path-clean",
|
"path-clean",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"rand",
|
"rand",
|
||||||
"rayon",
|
|
||||||
"rbx_binary",
|
"rbx_binary",
|
||||||
"rbx_cookie",
|
"rbx_cookie",
|
||||||
"rbx_dom_weak",
|
"rbx_dom_weak",
|
||||||
|
@ -1170,7 +1145,6 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tikv-jemallocator",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
"toml",
|
"toml",
|
||||||
|
@ -1223,15 +1197,6 @@ version = "2.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memoffset"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
version = "0.3.17"
|
version = "0.3.17"
|
||||||
|
@ -1588,26 +1553,6 @@ dependencies = [
|
||||||
"getrandom 0.2.11",
|
"getrandom 0.2.11",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rayon"
|
|
||||||
version = "1.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
"rayon-core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rayon-core"
|
|
||||||
version = "1.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
|
|
||||||
dependencies = [
|
|
||||||
"crossbeam-deque",
|
|
||||||
"crossbeam-utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rbx_binary"
|
name = "rbx_binary"
|
||||||
version = "0.7.3"
|
version = "0.7.3"
|
||||||
|
@ -2337,26 +2282,6 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tikv-jemalloc-sys"
|
|
||||||
version = "0.5.4+5.3.0-patched"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tikv-jemallocator"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"tikv-jemalloc-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.2.27"
|
version = "0.2.27"
|
||||||
|
|
|
@ -83,8 +83,6 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
mlua = { version = "0.9.1", features = ["luau", "luau-jit", "serialize"] }
|
mlua = { version = "0.9.1", features = ["luau", "luau-jit", "serialize"] }
|
||||||
tokio = { version = "1.24", features = ["full", "tracing"] }
|
tokio = { version = "1.24", features = ["full", "tracing"] }
|
||||||
os_str_bytes = { version = "6.4", features = ["conversions"] }
|
os_str_bytes = { version = "6.4", features = ["conversions"] }
|
||||||
[target.'cfg(not(target_env = "msvc"))'.dependencies]
|
|
||||||
tikv-jemallocator = "0.5"
|
|
||||||
|
|
||||||
### SERDE
|
### SERDE
|
||||||
|
|
||||||
|
@ -126,7 +124,6 @@ regex = { optional = true, version = "1.7", default-features = false, features =
|
||||||
"unicode-perl",
|
"unicode-perl",
|
||||||
] }
|
] }
|
||||||
rustyline = { optional = true, version = "12.0" }
|
rustyline = { optional = true, version = "12.0" }
|
||||||
rayon = "1.8"
|
|
||||||
|
|
||||||
### ROBLOX
|
### ROBLOX
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
use std::{env, ops::ControlFlow, process::ExitCode, sync::Mutex};
|
use std::{env, ops::ControlFlow, process::ExitCode};
|
||||||
|
|
||||||
use lune::Lune;
|
use lune::Lune;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use rayon::{
|
|
||||||
iter::{IndexedParallelIterator, ParallelIterator},
|
|
||||||
slice::ParallelSlice,
|
|
||||||
};
|
|
||||||
use tokio::fs::read as read_to_vec;
|
use tokio::fs::read as read_to_vec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,8 +33,8 @@ pub async fn check_env() -> (bool, Vec<u8>, Vec<u8>) {
|
||||||
Discovers, loads and executes the bytecode contained in a standalone binary.
|
Discovers, loads and executes the bytecode contained in a standalone binary.
|
||||||
*/
|
*/
|
||||||
pub async fn run_standalone(signature: Vec<u8>, bin: Vec<u8>) -> Result<ExitCode> {
|
pub async fn run_standalone(signature: Vec<u8>, bin: Vec<u8>) -> Result<ExitCode> {
|
||||||
let bytecode_offset = Mutex::new(0);
|
let mut bytecode_offset = 0;
|
||||||
let bytecode_size = Mutex::new(0);
|
let mut bytecode_size = 0;
|
||||||
|
|
||||||
// standalone binary structure (reversed, 8 bytes per field)
|
// standalone binary structure (reversed, 8 bytes per field)
|
||||||
// [0] => signature
|
// [0] => signature
|
||||||
|
@ -56,13 +52,10 @@ pub async fn run_standalone(signature: Vec<u8>, bin: Vec<u8>) -> Result<ExitCode
|
||||||
// The rchunks will have unequally sized sections in the beginning
|
// The rchunks will have unequally sized sections in the beginning
|
||||||
// but that doesn't matter to us because we don't need anything past the
|
// but that doesn't matter to us because we don't need anything past the
|
||||||
// middle chunks where the bytecode is stored
|
// middle chunks where the bytecode is stored
|
||||||
bin.par_rchunks(signature.len())
|
bin.rchunks(signature.len())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.try_for_each(|(idx, chunk)| {
|
.try_for_each(|(idx, chunk)| {
|
||||||
let mut bytecode_offset = bytecode_offset.lock().unwrap();
|
if bytecode_offset != 0 && bytecode_size != 0 {
|
||||||
let mut bytecode_size = bytecode_size.lock().unwrap();
|
|
||||||
|
|
||||||
if *bytecode_offset != 0 && *bytecode_size != 0 {
|
|
||||||
return ControlFlow::Break(());
|
return ControlFlow::Break(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,19 +65,16 @@ pub async fn run_standalone(signature: Vec<u8>, bin: Vec<u8>) -> Result<ExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
if idx == 3 {
|
if idx == 3 {
|
||||||
*bytecode_offset = u64::from_ne_bytes(chunk.try_into().unwrap());
|
bytecode_offset = u64::from_ne_bytes(chunk.try_into().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if idx == 2 {
|
if idx == 2 {
|
||||||
*bytecode_size = u64::from_ne_bytes(chunk.try_into().unwrap());
|
bytecode_size = u64::from_ne_bytes(chunk.try_into().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
});
|
});
|
||||||
|
|
||||||
let bytecode_offset_inner = bytecode_offset.into_inner().unwrap();
|
|
||||||
let bytecode_size_inner = bytecode_size.into_inner().unwrap();
|
|
||||||
|
|
||||||
// If we were able to retrieve the required metadata, we load
|
// If we were able to retrieve the required metadata, we load
|
||||||
// and execute the bytecode
|
// and execute the bytecode
|
||||||
|
|
||||||
|
@ -95,8 +85,8 @@ pub async fn run_standalone(signature: Vec<u8>, bin: Vec<u8>) -> Result<ExitCode
|
||||||
.with_args(args)
|
.with_args(args)
|
||||||
.run(
|
.run(
|
||||||
"STANDALONE",
|
"STANDALONE",
|
||||||
&bin[usize::try_from(bytecode_offset_inner)?
|
&bin[usize::try_from(bytecode_offset)?
|
||||||
..usize::try_from(bytecode_offset_inner + bytecode_size_inner)?],
|
..usize::try_from(bytecode_offset + bytecode_size)?],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,6 @@ pub(crate) mod executor;
|
||||||
use cli::Cli;
|
use cli::Cli;
|
||||||
use console::style;
|
use console::style;
|
||||||
|
|
||||||
#[cfg(not(target_env = "msvc"))]
|
|
||||||
use tikv_jemallocator::Jemalloc;
|
|
||||||
|
|
||||||
#[cfg(not(target_env = "msvc"))]
|
|
||||||
#[global_allocator]
|
|
||||||
static GLOBAL: Jemalloc = Jemalloc;
|
|
||||||
|
|
||||||
#[tokio::main(flavor = "multi_thread")]
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
async fn main() -> ExitCode {
|
async fn main() -> ExitCode {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
|
|
Loading…
Add table
Reference in a new issue