Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Ta©ti Tac0Z

make opencomputers processors faster

Question

i'm currecly useing CC becuse of the fact that the speed of witch lua commands is run is based on a speed factor in the processor item limiting the update speed of a program

OC is better that CC in all otherways then this, CC does not limit speed (not on purpes anyway) nor does it limit the amout of RAM a spesific computer can use (allso CC have made too much of an effort optimiseing the mod for servers makeing CC look like a simplyfired version of OC - witch i supose it is)

 

anyway of removieing (i know that ain't going to happen) the limit or at least let the computers run faster?

Link to post
Share on other sites

40 answers to this question

Recommended Posts

  • 1
  • Solution
23 minutes ago, noahthegame said:

but the hole idea is to being able to draw pixel per pixel

OC sets significant limits the GPU, which make it much harder to do more advanced graphics. You can optimize the calls at the cost of high RAM usage — storing data in a buffer and only drawing the cells that changed since the last buffer flush. It isn't really an easy thing to implement yourself, so you might want to use a buffering library someone else made — here's one that definitely works, for example. I was also making one, but it's not yet ready.

23 minutes ago, noahthegame said:

do you have any idea where OC gets the charector textures from?

OpenComputers has a font.hex file, which is the font that's used to render characters on the screen. Since OC 1.6, asie's funscii font is used.

28 minutes ago, noahthegame said:

is there some kind of unicode api

Let's make things clear.

  • Unicode is a standard that assigns numbers (codepoints) to a ton of characters (glyphs from different scripts, math symbols, emoji, and some other random things).
  • UTF-8 is one of the possible encodings for Unicode symbols, and it's fairly the most popular one used. It converts a character codepoint, like U+2588, to a sequence of bytes. We need an encoding because a byte can only contain 256 values, while Unicode has 137439 characters. OpenComputers (and a lot of other software) supports UTF-8 and uses it to encode characters.
  • OpenComputers provides the Unicode API for Lua 5.2 and Lua 5.3 architectures. You can use it to convert codepoints to characters and perform other operations on UTF-8 strings.
  • Lua 5.3 also exports the utf8 library. It has a few functions that Unicode API doesn't provide, but is unavailable for Lua 5.2.
Link to post
Share on other sites
  • 1

Please calm down.

There are some component methods that block the computer for a tick when called, yes. Such methods usually interact with the world. For example, a transposer allows to transfer items between invetories by calling the transferItem method, which takes a tick to execute (so you get up to 20 stacks/second).

On the other hand, there are a lot of direct methods, which can be called several times per tick. For example, the GPU's methods are direct. And the processor (as well as RAM) determines how many direct calls are allowed per tick. I think T2 T3 setup allows you to call gpu.get one thousand times every tick. Or 256 gpu.sets. Or 128 gpu.fills.

I also believe you don't realize how bad ComputerCraft is for servers. A really simple and stupidly-written program can eat up all the memory the server has. That's why OC limits the memory available for an in-game computer. And running CPU-intensive tasks on a CC's computer makes the whole server run slow, whereas OC requires scripts to pause to allow other in-game computer to run. OpenComputers imposes the limits not because the mod developers want users to suffer (although I do sometimes think of that when I try to do some stupidly complex things with it), but to make it server-friendly.

What's important is that OC allows you to configure these limits for your needs. Have you opened its configuration file? It is more than a 1.5k lines long, and has more than 300 settings you can change, each with a comment that explains the effect of the setting. There's callBudgets to increase the direct call number limit. Or decrease it. There's also the ramSizes setting for memory, and hddSizes for the HDD sizes.

But even with all of these limits, OC can run a lot of programs, including graphical shells, 3D games, reactor control systems. It allows you to send HTTP requests to the real websites, and open raw TCP sockets to interact with network services. It can display 320x200 images. It can even play videos — inside the game, and on the default OC settings!

Link to post
Share on other sites
  • 1

I'm not a moderator on these forums. I'm not Bomb block from CC I'm Molinko. I don't go around acting like a king. I attempt to answer questions from people seeking assistance, praise where I'm impressed, or criticism where I think it's due. You've made a post in a support forum basically complaining about the potential of OC. fin.

Edited by Molinko
trying not to be rude.
Link to post
Share on other sites
  • 1
On 8/19/2018 at 5:53 PM, noahthegame said:

you mean like this, right:


gfxb.clear()
gfxb.drawChanges(true)

if so then that doesn't work still nothing is drawen secount run

This behaviour is strange and indicates there's a bug somewhere. Since the double buffering library is used by MineOS, it would have much more chance of being noticed, so it's more likely there's some problem in your code. Could you show the code you run, please?

Link to post
Share on other sites
  • 0

The actual Lua interpreter in OC is probably faster than ComputerCraft - OpenComputers Lua is running natively most of the time, whereas ComputerCraft is running an interpreter written in Java.

That said, the performance hit you're describing is due to the limit on component calls. This is due to the fact that you can only do one component call per tick, for server performance reasons (Don't get me started on CC and server performance...). You can make them faster with the help of another mod, I believe it's Magic Bees, which adds a number of species of bees that manipulate how many ticks occur for blocks around a hive, making computers able to access components faster.

Link to post
Share on other sites
  • 0

but if thats the case what is the defrence betwine the processors then? i tested it once and there was a defrence of the speed

am really sad that OC (funny i said that about CC two hmmmm... at least CC only limits resolution and color) is doing so much to optimise servers the call limit makes it so am only allowed to call a screen command 4 times a sec even the 70/80's computers chould do 40 times that i know that whould breake a minecraft server at least have a singerplayer mode or some thing so i can breake my own computer then, if i chould i whold make my own perfect computer mod but emmm... but that ain't going to happen right now is it?

 

also once again: CC pulled it off why can't OC then?

Link to post
Share on other sites
  • 0
On 8/17/2018 at 5:53 PM, Fingercomp said:

But even with all of these limits, OC can run a lot of programs, including graphical shells, 3D games, reactor control systems. It allows you to send HTTP requests to the real websites, and open raw TCP sockets to interact with network services. It can display 320x200 images. It can even play videos — inside the game, and on the default OC settings!

all that but the resolotion thing computercraft can do as well but thats off topic tho

its true there is no RAM limit made by CC's code (CC have low resolution and 4bit color insted tho)

also the only way i can think of that 320X200 images is posible is with costom charectors

 

On 8/17/2018 at 5:53 PM, Fingercomp said:

 I think T2 setup allows you to call gpu.get one thousand times every tick

T2 means tier 2 right?

well yeah it only outputs some values from memory

 

On 8/17/2018 at 5:53 PM, Fingercomp said:

Or 256 gpu.sets

hmmm you're sure about this? where is the source? a while back i tryed to make a image format but it ran so slowly so it was unuseable i guess my format was extremly unoptimized then, now i made a format in CC witch runs both video (about 5/10 fps) and music at the same time

Link to post
Share on other sites
  • 0
cm = require("component")
term = require("term")

term.clear()

mx,my = cm.gpu.getResolution()

gpu = cm.gpu

i = -1

startTime = computer.uptime()

--while true do
  for x = 1,mx do
    for y = 1,my do
      i = i + 1

      if i == 0 then
        color = 0xff0000
      elseif i == 1 then
        color = 0x00ff00
      elseif i == 2 then
        color = 0x0000ff
      else
        color = 0xffff00
        i = -1
      end


      gpu.setBackground(color)

      gpu.set(x,y," ")
    end
  end

gpu.setBackground(0)
term.clear()
time = (computer.uptime()-startTime)
--print(os.time(), startTime)
print("it took")
print(time)




--end

(i forgot to add a require for computer)

that program draws a "checker-patten" (i belive its called) on the screen and prints how long time it takes in IRL sec as we can see the secs sems to avg. at 3.65 sec! (while useing the createive APU) so there most be a way to optimize this, right?

Link to post
Share on other sites
  • 0

Yeah, there is a way to make it faster. In fact, way faster. One of the things that makes it slow is... gpu.setBackground. It's quite expensive in terms of perfomance (tier 3 GPUs consume 1/128 of the call budget when this method is called). Fortunately, your program only involves 4 colors, so it can be easily optimized.

Actually, there are two ways to do it. A somewhat naive way would be to process all cells of one color first, then process all cells of another color, etc. That would solve the issue with gpu.setBackground, but there's another thing to worry about. The gpu.set method isn't free. In fact, that program does 160 × 50 = 8000 sets, assuming it's running on the max tier 3 resolution. And that is a lot.

Fortunately, OC supports Unicode. In particular, there's a character in Unicode called a full block — █. On OC, I prefer to think of it as of an inverse of " " (a space). If the foreground and background colors are swapped, the space would look like the full block, and vice versa. And it can help us reduce amount of GPU calls significantly. Try replacing the loops with the following:

-- i = 0
gpu.setBackground(0xff0000)
gpu.set(1, 1, " ")

-- i = 1
gpu.setBackground(0x00ff00)
gpu.set(1, 2, " ")

-- i = 2, 3
gpu.setForeground(0xffff00)
gpu.setBackground(0x0000ff)

local fullBlock = "\u{2588}"
local oddRow = (" " .. fullBlock):rep(math.floor(mx / 2))
local evenRow = (fullBlock .. " "):rep(math.floor(mx / 2))

for y = 1, my do
  local x = 1

  if y % 2 == 1 then
    if y == 1 then
      -- Shift the x by 2 to the right to avoid rewriting
      -- the first two characters.
      -- OC truncates everything that goes out of the screen bounds,
      -- so there's no need to worry about that.
      x = x + 2
    end

    gpu.set(x, y, oddRow)
  else
    gpu.set(x, y, evenRow)
  end
end

I can't launch Minecraft to run the program and measure the render time, but I can calculate the amount of call budget consumed by the GPU. Assuming the program runs on a tier 3 GPU and screen, there are 4 gpu.setForeground/gpu.setBackground calls, and 52 gpu.set calls. We get (4 × 1 / 128) + (52 × 1 / 256) = 15 / 64 ≈ 0.23. This is enough even if you have a tier 1 processor (whose call budget is 0.5), and the program should be able to run at 20 FPS, though it doesn't really change each frame.

8 hours ago, noahthegame said:

hmmm you're sure about this?

Oh, I meant to say "T3" (tier 3), sorry. A tier 2 GPU can only perform 128 sets and 64 fills.

8 hours ago, noahthegame said:

where is the source?

https://github.com/MightyPirates/OpenComputers/blob/master-MC1.7.10/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala#L55-L60

Also, there's a comment a few lines above in that file, which reminds me of yet another reason OC makes indirect calls take 1 tick to run — synchronization. OpenComputers, very much unlike ComputerCraft, saves the state of running computers so that they can be resumed when the chunk is reloaded. Methods that interact with the world in some way (like moving items around) must perform synchronization with the Minecraft world to avoid, well, messing things up. The comment says it's especially important on world saves. Despite that, the GPU methods were made direct, although a "nasty trick" was needed to do this. Well, safe concurrency is hard to achieve.

Link to post
Share on other sites
  • 0
1 hour ago, Fingercomp said:

OpenComputers has a font.hex file, which is the font that's used to render characters on the screen. Since OC 1.6, asie's funscii font is used.

ok, then

 

1 hour ago, Fingercomp said:

OC sets significant limits the GPU, which make it much harder to do more advanced graphics. You can optimize the calls at the cost of high RAM usage — storing data in a buffer and only drawing the cells that changed since the last buffer flush. It isn't really an easy thing to implement yourself, so you might want to use a buffering library someone else made — here's one that definitely works, for example. I was also making one, but it's not yet ready.so that

so i can see that buffer api thing have the standart gpu functions so i give the infomation to the buffer (eg buffer.set(2,2,0xff0000, 0, " ")) and the buffer api will only do a gpu.set opration when it has to limting unnessary gpu.set's? is that how that works?

Link to post
Share on other sites
  • 0
2 hours ago, noahthegame said:

so i give the infomation to the buffer (eg buffer.set(2,2,0xff0000, 0, " ")) and the buffer api will only do a gpu.set opration when it has to limting unnessary gpu.set's? is that how that works?

Yeah, basically.

1 hour ago, noahthegame said:

i think i have found a bug in the that buffering api it works once but then i need to restart the computer for it to work again? do i need to close the buffer before my program ends or some thing?

The buffer is a singleton. In other words, there's only a single buffer instance in the memory, which is kept there even if programs that required the library exited. An implication of this fact is that buffer may be non-empty when you start your program; therefore, before you use the buffer, you need to do a buffer.clear() followed by a forceful render: buffer.drawChanges(true). It's been a long time since I've used that library, though. Things might have changed. Considering there aren't proper releases and commit descriptions, it's rather difficult to navigate through the commit history.

Link to post
Share on other sites
  • 0

Noah, sometimes, you're just wrong/"don't get it", and that's okay. Fingercomp has tried to demonstrate that although OC has some limitations, they're there for arguably good reasons. Many of your issues in your initial post can be addressed with a config change. As for the buffer library, fingercomp was mentioning that's it's a Singleton. What he's trying to say basically is that the buffer data, or state, will be preserved from one program to the other. If you didn't know this you might think it was a bug... Basically what I'm trying to say is that you could use the forums more appropriately by asking better and more concise questions rather than a string of appearent complaints while also ignorant of the full capabilities of the mod. 

P.s Its not my intention to sound like a butthole..

Edited by Molinko
was a bit of a butthole
Link to post
Share on other sites
  • 0

the code is currenly 400lines long i there for don't want to post (and becuse even if it doesn't look like it i worked a lot for this project)  it here the code is located on my private webserver i don't want to give the hole community what i worked hard on am going to send you the url as a personal message i hope you understand

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.